<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>内部单位</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
    <form  action="bizInsideOrg/${action eq "create" ?"save":"update"}" name="inputForm" id="inputForm" method="post" class="form-horizontal">
    <input name="id" id="id" value="${entity.id}" type="hidden" />
    <div class="form-group">
        <label class="col-sm-1 control-label">单位名称：</label>
        <div class="col-md-3">
            <input type="text" class="form-control" name="orgName" value="${entity.orgName}" placeholder="单位名称">
        </div>
        <div class="col-sm-1"><span style="color: red">*</span></div>
        <label class="col-sm-1 control-label">负责人：</label>
        <div class="col-md-3">
            <input type="text" class="form-control" name="principal" value="${entity.principal}" placeholder="负责人">
        </div>
        <div class="col-sm-1"><span style="color: red">*</span></div>
    </div>
    <div class="form-group">
        <label class="col-sm-1 control-label">联系电话：</label>
        <div class="col-md-3">
            <input type="text" class="form-control" id="linkMobile" name="linkMobile" value="${entity.linkMobile}" placeholder="例：固定电话 025-81234567或手机13123456789">
        </div>
        <div class="col-sm-1"><span style="color: red">*</span></div>
    </div>
    <div class="form-group">
        <div class="col-sm-offset-1 col-sm-2">
            <button id="saveBtn" type="submit" class="btn btn-sm btn-primary"><i class="fa fa-floppy-o"></i> 提交</button>
            <button type="button" class="btn btn-sm link_close"><i class="fa fa-close"></i> 关闭</button>
        </div>
    </div>
    </form>
</div><!--/#main-container-->

<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script type="text/javascript">
    $(document).ready(function(e) {
        var options = {
            rules:{
                orgName : { required : true, maxlength : 20 },
                principal : { required : true, maxlength : 20 },
                linkMobile : { required : true, maxlength : 13 },
            },
            submitHandler:function(form){
                $(form).ajaxSubmit({
                    type:'post',
                    dataType:'json',
                    success:function(data){
                    	if(data.duplicate_key){
                        	layer.alert(data.msg);
                        }
                        if(data.success){
                            $('#searchBtn', parent.document).click();
                            closeIframe();
                        }else{
                            layer.alert(data.msg);
                        }
                    }
                });
            }
        };
        $("#inputForm").validate(options);
    });
    
    
    $("#linkMobile").blur(function(){ 
    	var mobile = $("#linkMobile").val();//焦点移除的时候进行验证
	    var reg = /^1[34578]\d{9}$|^((0\d{2,3}-\d{7,8}))$/;              //手机的格式
	            if (!reg.test(mobile)) {                //如果手机号码的格式与正则的不符合，就提醒
	                alert("联系方式格式有误，请重新输入");        
	                   return false;
	               }
    });
    
</script>
<!-- script end -->
</body>
</html>
